import request from '@/common/request.js';

//用户注册
export const registerApi = data => {
	return request.post({
		url: '/tube/user/register',
		data: data
	});
}

//用户登录
export const loginApi = data => {
	return request.post({
		url: '/tube/user/login',
		data: data
	});
}

//查询用户余额
export const queryUserBalanceApi = data => {
	return request.get({
		url: '/tube/user/queryUserBalance',
		data: data
	});
}


//用户修改
export const updateUsersApi = data => {
	return request.put({
		url: '/tube/user/updateUsers',
		data: data
	});
}



export const uploadApi = data => {
	return request.post({
		url: '/tube/admin/upload',
		data: data
	});
}

// 查询用户购物车
export const queryCartApi = data => {
	return request.get({
		url: '/tube/user/queryShoppings',
		data: data
	});
}

//修改购物车商品数量
export const updateCartApi = data => {
	return request.put({
		url: '/tube/admin/updateUsersCart',
		data: data
	});
}

//删除购物车单个商品
export const deleteOneGoodsApi = data => {
	return request.delete({
		url: '/tube/user/deleteOneShoppings',
		data: data
	});
}

//删除购物车批量商品
export const deleteManyShoppingsApi = data => {
	return request.delete({
		url: '/tube/user/deleteManyShoppings',
		data: data
	});
}

//查询用户地址
export const queryAddressApi = data => {
	return request.get({
		url: '/tube/user/queryUsersAddress',
		data: data
	});
}

//新增用户地址
export const createAddressApi = data => {
	return request.post({
		url: '/tube/user/createUsersAddress',
		data: data
	});
}


//设置用户默认地址
export const setdefaultAddressApi = data => {
	return request.post({
		url: '/tube/user/setdefaultAddress',
		data: data
	});
}

//修改用户地址
export const updateAddressApi = data => {
	return request.put({
		url: '/tube/user/updateUsersAddress',
		data: data
	});
}


// 小程序的delete机制跟pc有点不一样，小程序走的是微信自己写的请求函数uni.request, 用params传输的值除了get，基本都需要用ctx.request.body接收
//删除用户地址
export const deleteAddressApi = data => {
	return request.delete({
		url: `/tube/user/deleteUsersAddress`,
		data: data
	});
}

